import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;


public class DBuitls {
//	static String driver;
//	static String url;
//	static String user;
//	static String pwd;
//	static{
//		Properties p = new Properties();
//		InputStream in;
//		try {
//			in = DBuitls.class.getResourceAsStream("conn.properties");
////			in = new FileInputStream(new File("jdbc.properties"));//�ļ��ֽ�������
//			p.load(in);//���������ļ�
//			driver = (String) p.get("jdbc.driver");
//			url = (String) p.get("jdbc.url");
//			user = (String) p.get("jdbc.user");
//			pwd = (String) p.get("jdbc.pwd");
//		} catch (Exception e) {
//			e.printStackTrace();
//		} 
//	}
	public static Connection getConn(){
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		try {
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1?Unicode=true&characterEncoding=UTF-8","root","abc1");
			return conn;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	public static void close(Connection conn,Statement st,ResultSet rs){
		if(conn!=null){
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(st!=null){
			try {
				st.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(rs!=null){
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
}
